.TH std::counted_iterator::operator*,-> 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::counted_iterator::operator*,-> \- std::counted_iterator::operator*,->

.SH Synopsis
   constexpr decltype(auto) operator*();      \fB(1)\fP \fI(since C++20)\fP
   constexpr decltype(auto) operator*() const \fB(2)\fP \fI(since C++20)\fP
       requires /*dereferenceable*/<const I>;
   constexpr auto operator->() const noexcept \fB(3)\fP \fI(since C++20)\fP
       requires std::contiguous_iterator<I>;

   1,2) Returns a reference to the current element. The behavior is undefined if
   this->count() <= 0. The function's body is equivalent to return *current;.
   3) Returns a pointer to the current element. The function's body is equivalent to
   return std::to_address(current);.

.SH Parameters

   \fI(none)\fP

.SH Return value

   Reference or pointer to the current element.

.SH Example


// Run this code

 #include <complex>
 #include <iostream>
 #include <iterator>
 using std::operator""i;

 int main()
 {
     const auto il = {1.i, 2.i, 3.i, 4.i, 5.i};

     for (std::counted_iterator i{il.begin() + 1, 3}; i != std::default_sentinel; ++i)
         std::cout << *i << ' ';
     std::cout << '\\n';

     for (std::counted_iterator i{il.begin() + 1, 3}; i != std::default_sentinel; ++i)
         std::cout << i->imag() << ' ';
     std::cout << '\\n';
 }

.SH Output:

 (0,2) (0,3) (0,4)
 2 3 4

.SH See also

   operator[] accesses an element by index
   (C++20)    \fI(public member function)\fP
